package com.slg.android.listenbook.biz.bookcity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.slg.android.listenbook.R;

/**
 * Created by Thinkpad on 2015/3/24.
 */
public class RankFragmentAdapter extends BaseAdapter {

    private Context context;

    public RankFragmentAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return 4;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View ret = null;
        if (convertView != null) {
            ret = convertView;
        } else {
            ret = inflater.inflate(R.layout.item_rank_list, parent, false);
        }
        ViewHolder viewHolder = (ViewHolder) ret.getTag();
        if (viewHolder == null) {
            viewHolder = new ViewHolder();
            viewHolder.img = (ImageView) ret.findViewById(R.id.item_rank_fragment_img);
            viewHolder.title = (TextView) ret.findViewById(R.id.item_rank_text);

            ret.setTag(viewHolder);
        }
        switch (position) {
            case 0:
                viewHolder.img.setImageResource(R.drawable.icon_rank_hot);
                viewHolder.title.setText("推荐排行榜");

                break;
            case 1:
                viewHolder.img.setImageResource(R.drawable.icon_rank_good);
                viewHolder.title.setText("好评排行榜");

                break;
            case 2:
                viewHolder.img.setImageResource(R.drawable.icon_rank_search);
                viewHolder.title.setText("热搜排行榜");

                break;
            case 3:
                viewHolder.img.setImageResource(R.drawable.icon_rank_download);
                viewHolder.title.setText("下载排行榜");
                break;
        }

        return ret;
    }

    public class ViewHolder {
        private ImageView img;
        private TextView title;

    }

}
